
<?php
	include "kernel.php";
	include "adw_functions.php";
	
	
	$cr = GetActiveCompany();
?>

<?php
		echo "<center><h2>Reserves for active company $cr[realname]</h2>";
		
		//red f
		echo "<h3>Red fighters counts</h3>";		
		echo "<table border=1 width=50% cellspacing=5 cellpadding=5>";
		$r = mysql_query("select * from reserv where army=1 and typeOf='f' and company_id='$cr[id]' order by maxcount DESC");				
		while ($res = mysql_fetch_assoc($r)) 
		{		
				
			$plname = GetPlaneNameById($res['plane_id']); 			
			
			$bg='';
			if ($res['maxcount'] < $res['busycount'])
				$bg='bgcolor=red';
				
			echo "<tr $bg><td align=center>$plname</td><td align=center>$res[busycount] / $res[maxcount]</td></tr>";			
		}		
		echo "</table>";
		
		//red b
		echo "<h3>Red bombers counts</h3>";		
		echo "<table border=1 width=50% cellspacing=5 cellpadding=5>";
		$r = mysql_query("select * from reserv where army=1 and typeOf='b' and company_id='$cr[id]' order by maxcount DESC");				
		while ($res = mysql_fetch_assoc($r)) 
		{			
			$plname = GetPlaneNameById($res['plane_id']); 			
			
			$bg='';
			if ($res['maxcount'] < $res['busycount'])
				$bg='bgcolor=red';
				
			echo "<tr $bg><td align=center>$plname</td><td align=center>$res[busycount] / $res[maxcount]</td></tr>";			
		}		
		echo "</table>";		
		
		//blue f
		echo "<h3>Blue fighters counts</h3>";		
		echo "<table border=1 width=50% cellspacing=5 cellpadding=5>";
		$r = mysql_query("select * from reserv where army=2 and typeOf='f' and company_id='$cr[id]' order by maxcount DESC");				
		while ($res = mysql_fetch_assoc($r)) 
		{			
			$plname = GetPlaneNameById($res['plane_id']); 			

			$bg='';
			if ($res['maxcount'] < $res['busycount'])
				$bg='bgcolor=red';
							
			echo "<tr $bg><td align=center>$plname</td><td align=center>$res[busycount] / $res[maxcount]</td></tr>";			
		}		
		echo "</table>";		
		
		
		//blue b
		echo "<h3>Blue bombers counts</h3>";		
		echo "<table border=1 width=50% cellspacing=5 cellpadding=5>";
		$r = mysql_query("select * from reserv where army=2 and typeOf='b' and company_id='$cr[id]' order by maxcount DESC");				
		while ($res = mysql_fetch_assoc($r)) 
		{			
			$plname = GetPlaneNameById($res['plane_id']); 			
			
			$bg='';
			if ($res['maxcount'] < $res['busycount'])
				$bg='bgcolor=red';
							
			echo "<tr $bg><td align=center>$plname</td><td align=center>$res[busycount] / $res[maxcount]</td></tr>";			
		}		
		echo "</table>";		
	
?>
</centeR>